
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @module session
* @author: Hjava
* @description: Login相关协议
* @since: 2018-07-16 14:26:49
*/
var constant_1 = __webpack_require__(/*! _login/constant */ "./src/core/login/constant.ts");
var bufferType_1 = __webpack_require__(/*! _util/bufferType */ "./src/core/utils/bufferType.ts");
var deviceInfo_1 = __webpack_require__(/*! _util/deviceInfo */ "./src/core/utils/deviceInfo.ts");
var protocol_1 = __webpack_require__(/*! _util/protocol */ "./src/core/utils/protocol.ts");
var userData_1 = __webpack_require__(/*! _util/userData */ "./src/core/utils/userData.ts");
var clientInfo_1 = __webpack_require__(/*! _util/clientInfo */ "./src/core/utils/clientInfo.ts");
var constant_2 = __webpack_require__(/*! _util/constant */ "./src/core/utils/constant.ts");
//todo 和敦飏对齐,需要给微信小程序增加一个单独的OS
function getOS(dt) {
    if (dt === 4) {
        if (clientInfo_1.default.getClientInfo().os === 'Mac') {
            return constant_2.OS.OS_MAC;
        }
        else {
            return constant_2.OS.OS_WINDOWS;
        }
    }
    return constant_2.OS.OS_WEB;
}
/**
 * 登录响应
 * @type {Function}
 */
var LoginRes = protocol_1.default.Response.extend({
    uri: [constant_1.default.Login.PLOGINBYPASSPORTRES_URI, constant_1.default.Login.PLOGINBYUIDRES_URI, constant_1.default.Login.PVISITORLOGINRES_URI],
    __master: true,
    unmarshall: function () {
        this.rescode = this.popInt();
        this.uid = this.popLong().value();
        this.cookie = this.popString();
        this.deviceData = this.popString();
        this.altoken = this.popString();
        this.channel_map = this.popMapOfShortAndInt();
    }
});
/**
 * PassWord登录策略Req
 */
var PassportReq = protocol_1.default.Request.extend({
    __master: true,
    uri: constant_1.default.Login.PLOGINBYPASSPORT_URI,
    init: function () {
        //用户名
        this.passport = '';
        //密码
        this.password = '';
        //设备唯一id
        this.deviceid = userData_1.default.get('deviceId');
        //客户端版本号
        this.version = "4.22.144";
        //operation system
        this.os = getOS(deviceInfo_1.default.deviceType);
        //sdk的内部版本号，数字
        this.sdkVersion = 1;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.pushToken = '';
        this.deviceData = '';
        this.supportMultiDevices = false;
        this.traceId = 0;
        this.swimlane = userData_1.default.get('swimlane') || '';
        this.capacity = 200;
    },
    marshall: function () {
        this.push(this.passport, bufferType_1.default.STRING);
        this.push(this.password, bufferType_1.default.STRING);
        this.push(this.deviceid, bufferType_1.default.STRING);
        this.push(this.version, bufferType_1.default.STRING);
        this.push(this.os, bufferType_1.default.SHORT);
        this.push(this.sdkVersion, bufferType_1.default.INT);
        this.push(this.deviceType, bufferType_1.default.SHORT);
        this.push(this.pushToken, bufferType_1.default.STRING);
        this.push(this.deviceData, bufferType_1.default.STRING);
        this.push(this.supportMultiDevices, bufferType_1.default.BOOLEAN);
        this.push(this.traceId, bufferType_1.default.LONG);
        this.push(this.swimlane, bufferType_1.default.STRING);
    }
});
/**
 * UID登录策略Req
 */
var UidReq = protocol_1.default.Request.extend({
    __master: true,
    uri: constant_1.default.Login.PLOGINBYUID_URI,
    init: function () {
        // 用户uid
        this.uid = '';
        // 用户操作系统
        this.os = getOS(deviceInfo_1.default.deviceType);
        // sdk的内部版本号，数字
        this.sdkVersion = 1;
        // cookie
        this.cookie = '';
        // 设备唯一id
        this.deviceid = userData_1.default.get('deviceId');
        // 客户端版本号
        this.version = "4.22.144";
        // DeviceType
        this.deviceType = deviceInfo_1.default.deviceType;
        this.pushToken = '';
        this.deviceData = '';
        this.supportMultiDevices = false;
        this.traceId = 0;
        this.swimlane = userData_1.default.get('swimlane') || '';
        this.capacity = 200;
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.os, bufferType_1.default.SHORT);
        this.push(this.sdkVersion, bufferType_1.default.INT);
        this.push(this.cookie, bufferType_1.default.STRING);
        this.push(this.deviceid, bufferType_1.default.STRING);
        this.push(this.version, bufferType_1.default.STRING);
        this.push(this.deviceType, bufferType_1.default.SHORT);
        this.push(this.pushToken, bufferType_1.default.STRING);
        this.push(this.deviceData, bufferType_1.default.STRING);
        this.push(this.supportMultiDevices, bufferType_1.default.BOOLEAN);
        this.push(this.traceId, bufferType_1.default.LONG);
        this.push(this.swimlane, bufferType_1.default.STRING);
    }
});
/**
 * PKickoff
 * @type {Function}
 */
var KickOff = protocol_1.default.Response.extend({
    uri: constant_1.default.Login.PKICKOFF_URI,
    __master: true,
    unmarshall: function () {
        this.uid = this.popLong().value(); //被踢人的uid
        this.appid = this.popShort();
        this.reason = this.popShort(); //被踢原因，KICK_MULTI为多登陆被踢，即同种app同一时间登陆同一个帐号
    }
});
var KickOffWithSameDeviceId = protocol_1.default.Response.extend({
    uri: constant_1.default.Login.PKICKOFFWITHSAMEDEVICEID_URI,
    __master: true,
    init: function () {
        this.uid = 0;
        this.appId = 0;
        this.deviceType = 0;
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.appId = this.popShort();
        this.deviceType = this.popShort();
    }
});
/**
 * LogoutReq
 * @type {Protocol.Request|*}
 */
var LogoutReq = protocol_1.default.Request.extend({
    __master: true,
    init: function () {
        this.uri = constant_1.default.Login.PLOGOUT_URI;
        this.uid = 0;
        this.traceId = 0;
        this.swimlane = userData_1.default.get('swimlane') || '';
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.traceId, bufferType_1.default.LONG);
        this.push(this.swimlane, bufferType_1.default.STRING);
    }
});
/**
 * 同步服务器时间
 * @type {Function}
 */
var SvrTimeRes = protocol_1.default.Response.extend({
    uri: constant_1.default.Login.PQRYSRVTIMESTAMPRES_URI,
    unmarshall: function () {
        this.client_tsms = this.popLong().value(); //客户端时间截，毫秒级别
        this.server_tsms = this.popLong().value(); //服务器时间截，毫秒级别
    }
});
/**
 * 同步服务器时间Req
 * @type {Protocol.Request|*}
 */
var AdjustByServerStampReq = protocol_1.default.Request.extend({
    __master: true,
    init: function () {
        this.uri = constant_1.default.Login.PQRYSRVTIMESTAMP_URI;
        this.client_tsms = new Date().getTime();
        this.capacity = 100;
    },
    marshall: function () {
        this.push(this.client_tsms, bufferType_1.default.LONG);
    }
});
/**
 * client detect
 * @type {Function}
 */
var Detect = protocol_1.default.Response.extend({
    __master: true,
    uri: constant_1.default.Login.PDETECTCLIENT_URI,
    unmarshall: function () {
        this.server_tsms = this.popLong().value();
    }
});
/**
 * PingReq
 */
var Ping = protocol_1.default.Response.extend({
    __master: true,
    uri: constant_1.default.Login.PLOGINPING_URI,
    init: function () {
        this.uid = '';
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.uid = this.popLong();
    }
});
/**
 * DetectClientAckReq
 */
var DetectAck = protocol_1.default.Request.extend({
    __master: true,
    uri: constant_1.default.Login.PDETECTCLIENTACK_URI,
    init: function () {
        this.uid = '';
        this.server_tsms = '';
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.server_tsms, bufferType_1.default.LONG);
    }
});
var VisitorReq = protocol_1.default.Request.extend({
    __master: true,
    uri: constant_1.default.Login.PVISITORLOGIN_URI,
    init: function () {
        this.uid = '';
        this.os = 3;
        this.sdkversion = 0;
        this.xsid = '';
        this.deviceid = userData_1.default.get('deviceId');
        this.version = "4.22.144";
        this.device_type = deviceInfo_1.default.deviceType;
        this.pushToken = '';
        this.deviceData = '';
        this.supportMultiDevices = false;
        this.traceId = 0;
        this.swimlane = userData_1.default.get('swimlane') || '';
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.os, bufferType_1.default.SHORT);
        this.push(this.sdkversion, bufferType_1.default.INT);
        this.push(this.xsid, bufferType_1.default.STRING);
        this.push(this.deviceid, bufferType_1.default.STRING);
        this.push(this.version, bufferType_1.default.STRING);
        this.push(this.device_type, bufferType_1.default.SHORT);
        this.push(this.pushToken, bufferType_1.default.STRING);
        this.push(this.deviceData, bufferType_1.default.STRING);
        this.push(this.supportMultiDevices, bufferType_1.default.BOOLEAN);
        this.push(this.traceId, bufferType_1.default.LONG);
        this.push(this.swimlane, bufferType_1.default.STRING);
    }
});
exports.default = {
    LoginRes: LoginRes,
    PassportReq: PassportReq,
    UidReq: UidReq,
    KickOff: KickOff,
    KickOffWithSameDeviceId: KickOffWithSameDeviceId,
    LogoutReq: LogoutReq,
    SvrTimeRes: SvrTimeRes,
    AdjustByServerStampReq: AdjustByServerStampReq,
    Detect: Detect,
    Ping: Ping,
    DetectAck: DetectAck,
    VisitorReq: VisitorReq
};


//# sourceURL=webpack://MTDX/./src/core/login/session.ts?